package com.peng.ivos.geofence.controller;

import com.peng.ivos.base.response.JsonResult;
import com.peng.ivos.geofence.pojo.dto.GeofenceParam;
import com.peng.ivos.geofence.pojo.dto.GeofenceQuery;
import com.peng.ivos.geofence.service.GeofenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 电子围栏控制层接口
 * @author： Peng
 * @date： 2024/5/23
 * @version: 1.0
 */
@RestController
@RequestMapping("/v1/geofence")
@Slf4j
@Api(tags = "电子围栏控制器")
public class GeofenceController {
    @Autowired
    private GeofenceService geofenceService;

    /**
     * 查询围栏列表
     * @param geofenceQuery 查询围栏参数
     * @return
     */
    @ApiOperation("查询围栏列表")
    @GetMapping("/select")
    public JsonResult getGeofenceList(GeofenceQuery geofenceQuery) {
        log.debug("查询参数：{}",geofenceQuery);
        return geofenceService.getGeofenceList(geofenceQuery);
    }

    @PostMapping("/save")
    public JsonResult saveGeofence(GeofenceParam geofenceParam){
        log.debug("新增围栏参数：{}",geofenceParam);
        return geofenceService.saveGeofence(geofenceParam);
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteGeofence(@PathVariable Long id){
        log.debug("删除围栏id：{}",id);
        return geofenceService.deleteGeofence(id);
    }
}
